package mage;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import mage.factory.handler.CardCreatorHandler;
import mage.factory.handler.MetaHandler;
import mage.factory.handler.SetHandler;

import org.xml.sax.SAXException;

public class MainFactory {
	public static void main(String[] args) {
		SAXParserFactory factory = SAXParserFactory.newInstance();
		try {
	    	SAXParser saxParser = factory.newSAXParser();
	    	SetHandler sh = new SetHandler();
			saxParser.parse("resources\\setinfo.xml", sh);
			sh.toFile("src\\mage\\sets","unlimitededition");
			
			MetaHandler mh = new MetaHandler();
			saxParser.parse("resources\\meta.xml", mh);
			//mh.toFile("resources\\");
			
			CardCreatorHandler ch = new CardCreatorHandler();
			ch.setNameToSet(mh.getNameToSet());
			saxParser.parse("resources\\cards.xml", ch);
			ch.toFile("resources");
			//ch.toClass(sh.getElements(),"src\\mage\\sets");
			ch.toRule("rules.csv");
			
			
		} catch (SAXException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
	}
}
